package com.yxd.express.dao.ordermaster;

import com.yxd.express.dao.BaseHibernateDAO;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A data access object (DAO) providing persistence and search support for
 * OrderMaster entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.yxd.express.dao.ordermaster.OrderMaster
 * @author MyEclipse Persistence Tools
 */

public class OrderMasterDAO extends BaseHibernateDAO {
	private static final Logger log = LoggerFactory
			.getLogger(OrderMasterDAO.class);
	// property constants
	public static final String ORDER_WAYBILL_NO = "orderWaybillNo";
	public static final String CUSTOMER_ID = "customerId";
	public static final String CONTACT_ID = "contactId";
	public static final String TRANS_TYPE_ID = "transTypeId";
	public static final String CONSIGNEE_AREA_CODE = "consigneeAreaCode";
	public static final String CONSIGNEE_ADDRESS_ID = "consigneeAddressId";
	public static final String DESTINATION_AREA_CODE = "destinationAreaCode";
	public static final String CONSIGNEE_ID = "consigneeId";
	public static final String CONSIGNEE_CONTACT_ID = "consigneeContactId";
	public static final String DESTINATION_ADRESS_ID = "destinationAdressId";
	public static final String GET_PERSON_ID = "getPersonId";
	public static final String SEND_PERSON_ID = "sendPersonId";
	public static final String ORDER_ORGANIZATIO_ID = "orderOrganizatioId";
	public static final String OPERATION_ORGANIZATIO_ID = "operationOrganizatioId";
	public static final String SEND_ORGANIZATIO_ID = "sendOrganizatioId";
	public static final String PLATE_NUMBER = "plateNumber";
	public static final String PIECE = "piece";
	public static final String PROBABLY_WEIGHT = "probablyWeight";
	public static final String PROBABLY_VOLUME = "probablyVolume";
	public static final String PROBABLY_LENGH = "probablyLengh";
	public static final String PROBABLY_WIDTH = "probablyWidth";
	public static final String PROBABLY_HEIGHT = "probablyHeight";
	public static final String GROSS_WEIGHT = "grossWeight";
	public static final String NET_WEIGHT = "netWeight";
	public static final String CHARGED_WEIGHT = "chargedWeight";
	public static final String VOLUME = "volume";
	public static final String LENGH = "lengh";
	public static final String WIDTH = "width";
	public static final String HEIGHT = "height";
	public static final String IS_RETURN = "isReturn";
	public static final String IS_EXCEPTION = "isException";
	public static final String IS_CASH_ORDER = "isCashOrder";
	public static final String IS_SUP_VALUE = "isSupValue";
	public static final String IS_COLLECTING = "isCollecting";
	public static final String PAY_TYPE_ID = "payTypeId";
	public static final String GET_TYPE_ID = "getTypeId";
	public static final String SEND_TYPE_ID = "sendTypeId";
	public static final String PACK_TYPE_ID = "packTypeId";
	public static final String UNIT_PRICE = "unitPrice";
	public static final String CARGO_DESCRIPTION = "cargoDescription";
	public static final String PRECAUTIONS = "precautions";
	public static final String ORDER_MASTER_STATE_ID = "orderMasterStateId";
	public static final String IS_NOTIFY = "isNotify";
	public static final String IS_SIGN_FOR = "isSignFor";
	public static final String SIGN_FOR_TYPE_ID = "signForTypeId";
	public static final String YSCHARGE_SUBMIT_STATE_ID = "yschargeSubmitStateId";
	public static final String YFCHARGE_SUBMIT_STATE_ID = "yfchargeSubmitStateId";
	public static final String CREATE_BY = "createBy";
	public static final String MODIFIED_BY = "modifiedBy";
	public static final String AUDIT_BY = "auditBy";
	public static final String ABOLISH_BY = "abolishBy";
	public static final String DELETION_STATE_CODE = "deletionStateCode";
	public static final String REMARK = "remark";
	public static final String UNIQUE_ID = "uniqueId";

	public void save(OrderMaster transientInstance) {
		log.debug("saving OrderMaster instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(OrderMaster persistentInstance) {
		log.debug("deleting OrderMaster instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public OrderMaster findById(java.lang.String id) {
		log.debug("getting OrderMaster instance with id: " + id);
		try {
			OrderMaster instance = (OrderMaster) getSession().get(
					"com.yxd.express.dao.ordermaster.OrderMaster", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(OrderMaster instance) {
		log.debug("finding OrderMaster instance by example");
		try {
			List results = getSession().createCriteria(
					"com.yxd.express.dao.ordermaster.OrderMaster").add(
					Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding OrderMaster instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from OrderMaster as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByOrderWaybillNo(Object orderWaybillNo) {
		return findByProperty(ORDER_WAYBILL_NO, orderWaybillNo);
	}

	public List findByCustomerId(Object customerId) {
		return findByProperty(CUSTOMER_ID, customerId);
	}

	public List findByContactId(Object contactId) {
		return findByProperty(CONTACT_ID, contactId);
	}

	public List findByTransTypeId(Object transTypeId) {
		return findByProperty(TRANS_TYPE_ID, transTypeId);
	}

	public List findByConsigneeAreaCode(Object consigneeAreaCode) {
		return findByProperty(CONSIGNEE_AREA_CODE, consigneeAreaCode);
	}

	public List findByConsigneeAddressId(Object consigneeAddressId) {
		return findByProperty(CONSIGNEE_ADDRESS_ID, consigneeAddressId);
	}

	public List findByDestinationAreaCode(Object destinationAreaCode) {
		return findByProperty(DESTINATION_AREA_CODE, destinationAreaCode);
	}

	public List findByConsigneeId(Object consigneeId) {
		return findByProperty(CONSIGNEE_ID, consigneeId);
	}

	public List findByConsigneeContactId(Object consigneeContactId) {
		return findByProperty(CONSIGNEE_CONTACT_ID, consigneeContactId);
	}

	public List findByDestinationAdressId(Object destinationAdressId) {
		return findByProperty(DESTINATION_ADRESS_ID, destinationAdressId);
	}

	public List findByGetPersonId(Object getPersonId) {
		return findByProperty(GET_PERSON_ID, getPersonId);
	}

	public List findBySendPersonId(Object sendPersonId) {
		return findByProperty(SEND_PERSON_ID, sendPersonId);
	}

	public List findByOrderOrganizatioId(Object orderOrganizatioId) {
		return findByProperty(ORDER_ORGANIZATIO_ID, orderOrganizatioId);
	}

	public List findByOperationOrganizatioId(Object operationOrganizatioId) {
		return findByProperty(OPERATION_ORGANIZATIO_ID, operationOrganizatioId);
	}

	public List findBySendOrganizatioId(Object sendOrganizatioId) {
		return findByProperty(SEND_ORGANIZATIO_ID, sendOrganizatioId);
	}

	public List findByPlateNumber(Object plateNumber) {
		return findByProperty(PLATE_NUMBER, plateNumber);
	}

	public List findByPiece(Object piece) {
		return findByProperty(PIECE, piece);
	}

	public List findByProbablyWeight(Object probablyWeight) {
		return findByProperty(PROBABLY_WEIGHT, probablyWeight);
	}

	public List findByProbablyVolume(Object probablyVolume) {
		return findByProperty(PROBABLY_VOLUME, probablyVolume);
	}

	public List findByProbablyLengh(Object probablyLengh) {
		return findByProperty(PROBABLY_LENGH, probablyLengh);
	}

	public List findByProbablyWidth(Object probablyWidth) {
		return findByProperty(PROBABLY_WIDTH, probablyWidth);
	}

	public List findByProbablyHeight(Object probablyHeight) {
		return findByProperty(PROBABLY_HEIGHT, probablyHeight);
	}

	public List findByGrossWeight(Object grossWeight) {
		return findByProperty(GROSS_WEIGHT, grossWeight);
	}

	public List findByNetWeight(Object netWeight) {
		return findByProperty(NET_WEIGHT, netWeight);
	}

	public List findByChargedWeight(Object chargedWeight) {
		return findByProperty(CHARGED_WEIGHT, chargedWeight);
	}

	public List findByVolume(Object volume) {
		return findByProperty(VOLUME, volume);
	}

	public List findByLengh(Object lengh) {
		return findByProperty(LENGH, lengh);
	}

	public List findByWidth(Object width) {
		return findByProperty(WIDTH, width);
	}

	public List findByHeight(Object height) {
		return findByProperty(HEIGHT, height);
	}

	public List findByIsReturn(Object isReturn) {
		return findByProperty(IS_RETURN, isReturn);
	}

	public List findByIsException(Object isException) {
		return findByProperty(IS_EXCEPTION, isException);
	}

	public List findByIsCashOrder(Object isCashOrder) {
		return findByProperty(IS_CASH_ORDER, isCashOrder);
	}

	public List findByIsSupValue(Object isSupValue) {
		return findByProperty(IS_SUP_VALUE, isSupValue);
	}

	public List findByIsCollecting(Object isCollecting) {
		return findByProperty(IS_COLLECTING, isCollecting);
	}

	public List findByPayTypeId(Object payTypeId) {
		return findByProperty(PAY_TYPE_ID, payTypeId);
	}

	public List findByGetTypeId(Object getTypeId) {
		return findByProperty(GET_TYPE_ID, getTypeId);
	}

	public List findBySendTypeId(Object sendTypeId) {
		return findByProperty(SEND_TYPE_ID, sendTypeId);
	}

	public List findByPackTypeId(Object packTypeId) {
		return findByProperty(PACK_TYPE_ID, packTypeId);
	}

	public List findByUnitPrice(Object unitPrice) {
		return findByProperty(UNIT_PRICE, unitPrice);
	}

	public List findByCargoDescription(Object cargoDescription) {
		return findByProperty(CARGO_DESCRIPTION, cargoDescription);
	}

	public List findByPrecautions(Object precautions) {
		return findByProperty(PRECAUTIONS, precautions);
	}

	public List findByOrderMasterStateId(Object orderMasterStateId) {
		return findByProperty(ORDER_MASTER_STATE_ID, orderMasterStateId);
	}

	public List findByIsNotify(Object isNotify) {
		return findByProperty(IS_NOTIFY, isNotify);
	}

	public List findByIsSignFor(Object isSignFor) {
		return findByProperty(IS_SIGN_FOR, isSignFor);
	}

	public List findBySignForTypeId(Object signForTypeId) {
		return findByProperty(SIGN_FOR_TYPE_ID, signForTypeId);
	}

	public List findByYschargeSubmitStateId(Object yschargeSubmitStateId) {
		return findByProperty(YSCHARGE_SUBMIT_STATE_ID, yschargeSubmitStateId);
	}

	public List findByYfchargeSubmitStateId(Object yfchargeSubmitStateId) {
		return findByProperty(YFCHARGE_SUBMIT_STATE_ID, yfchargeSubmitStateId);
	}

	public List findByCreateBy(Object createBy) {
		return findByProperty(CREATE_BY, createBy);
	}

	public List findByModifiedBy(Object modifiedBy) {
		return findByProperty(MODIFIED_BY, modifiedBy);
	}

	public List findByAuditBy(Object auditBy) {
		return findByProperty(AUDIT_BY, auditBy);
	}

	public List findByAbolishBy(Object abolishBy) {
		return findByProperty(ABOLISH_BY, abolishBy);
	}

	public List findByDeletionStateCode(Object deletionStateCode) {
		return findByProperty(DELETION_STATE_CODE, deletionStateCode);
	}

	public List findByRemark(Object remark) {
		return findByProperty(REMARK, remark);
	}

	public List findByUniqueId(Object uniqueId) {
		return findByProperty(UNIQUE_ID, uniqueId);
	}

	public List findAll() {
		log.debug("finding all OrderMaster instances");
		try {
			String queryString = "from OrderMaster";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public OrderMaster merge(OrderMaster detachedInstance) {
		log.debug("merging OrderMaster instance");
		try {
			OrderMaster result = (OrderMaster) getSession().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(OrderMaster instance) {
		log.debug("attaching dirty OrderMaster instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(OrderMaster instance) {
		log.debug("attaching clean OrderMaster instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}